package com.springboot.mail.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.springboot.mail.common.ResultUtil;
import com.springboot.mail.common.bean.MyResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "登录模块")
@ApiSupport(author = "LY L")
@RestController
@RequestMapping(value = "", produces = {"application/json;charset=UTF-8"})
@Slf4j
//@Validated     // springboot 2.5.* 版本需要在类上标注 @Validated 注解校验注解才会生效。
public class DemoController {


    @ApiOperation("测试")
    @GetMapping("/demo")
    public MyResult<String> isLogin() {
        // StpUtil.isLogin() 查询当前客户端是否登录，返回 true 或 false
        return StpUtil.isLogin() ? ResultUtil.success("已登录。。") : ResultUtil.error("未登录！！");
    }
}